<html>
<title>plus-appengine-sample</title>
<body>
  <h2>Instructions for the Plus App Engine Sample</h2>

  <h3>Browse Source Code</h3>

  <ul>
    <li><a
      href="http://code.google.com/p/google-api-java-client/source/browse/plus-appengine-sample/?repo=samples">Browse
        Source</a>
  </ul>

  <h3>Register Your Application</h3>

  <ul>
    <li>Visit the <a href="https://cloud.google.com/console/start/api?id=plus">Google Cloud
        console</a>.
    </li>
    <li>If necessary, sign in to your Google Account, select or create a project,
        and agree to the terms of service.  Click Continue.</li>
    <li>Select the "Web Application" platform, and click Register.</li>
    <li>Within "OAuth 2.0 Client ID", click on "Download JSON". Later on, after you check
        out the sample project, you will copy this downloaded file (e.g.
        <code>~/Downloads/client_secrets.json</code>) to
        <a href="src/main/resources/client_secrets.json">src/main/resources/client_secrets.json</a>.
        If you skip this step, when trying to run the sample you will get a <code>400
        INVALID_CLIENT</code> error in the browser.
    </li>
    <li>Within "OAuth 2.0 Client ID", in the "Redirect URI" field enter some
        redirect URIs, for example
        "https://yourappname.appspot.com/oauth2callback" and
        "http://localhost:8888/oauth2callback".
    </li>
    <li>In the section labeled "Server Key", copy the value of "API KEY".
        Go to <a href="src/main/java/com/google/api/services/samples/plus/PlusBasicServlet.java">
        src/main/java/com/google/api/services/samples/plus/PlusBasicServlet.java</a>
        and find the variable named "API_KEY". Paste the value from the API
        Console into the quotes for API_KEY.
    </li>
  </ul>

  <h3>Checkout Instructions</h3>

  <p>
    <b>Prerequisites:</b> install <a href="http://java.com">Java 6</a>, <a
      href="https://developers.google.com/appengine/downloads">Google App
      Engine</a>, <a href="http://mercurial.selenic.com/">Mercurial</a>, and <a
      href="http://maven.apache.org/download.html">Maven</a>. You may need to
    set your
    <code>JAVA_HOME</code>
    .
  </p>

  <pre>
cd <i>[someDirectory]</i>
hg clone https://code.google.com/p/google-api-java-client.samples/ google-api-java-client-samples
cd google-api-java-client-samples/plus-appengine-sample
cp ~/Downloads/client_secrets.json src/main/resources/client_secrets.json
mvn clean package
  </pre>

  <p>To enable logging of HTTP requests and responses (highly recommended
    when developing), please take a look at <a href="src/main/webapp/WEB-INF/logging.properties">logging.properties</a>.</p>
    
  <h3>Running and Deploying Your Application from the Command Line</h3>
  
  <p>To run your application locally on a development server:</p>
  <pre>
mvn appengine:devserver
  </pre>
  
  <p>To deploy your application to appspot.com:</p>
  
  <p>
    If this is the first time you are deploying your application to appspot.com, you will to perform the 
    following steps first.
  </p>
    
  <ul>
    <li>Go to <a href="https://appengine.google.com/">https://appengine.google.com</a> and create an application.</li>
    <li>Edit src/main/webapp/WEB-INF/appengine-web.xml, and enter the unique application identifier (you chose it in the prior step)
     between the &lt;application&gt; tags.</li>
  </ul>

  <p> If you've done the above, you can deploy at any time: </p> 
<pre>
mvn appengine:update
</pre>

 <p>If this is the first time you have run "update" on the project, a browser window will open prompting you to log in.
  Log in with the same Google account the app is registered with.
 </p>


  <h3>Setup Project in Eclipse</h3>

  <p>
    <b>Prerequisites:</b> install <a href="http://www.eclipse.org/downloads/">Eclipse</a>,
    <a href="http://code.google.com/eclipse/">Google Plugin for Eclipse</a>, and
    the <a href="http://javaforge.com/project/HGE">Mercurial plugin</a>.
  </p>

  <ul>
    <li>Setup Eclipse Preferences
      <ul>
        <li>Window &gt; Preferences... (or on Mac, Eclipse &gt;
          Preferences...)</li>
        <li>Select Maven
          <ul>
            <li>check on "Download Artifact Sources"</li>
            <li>check on "Download Artifact JavaDoc"</li>
          </ul>
        </li>
      </ul>
    </li>
    <li>Import <code>plus-appengine-sample</code> project
      <ul>
        <li>File &gt; Import...</li>
        <li>Select "General &gt; Existing Project into Workspace" and click
          "Next"</li>
        <li>Click "Browse" next to "Select root directory", find <code>
            <i>[someDirectory]</i>/google-api-java-client-samples/plus-appengine-sample
          </code> and click "Next"
        </li>
        <li>Click "Finish"</li>
        <li>NOTE: please ignore the "The App Engine SDK JAR * is missing in
          the WEB-INF/lib directory" error messages.</li>
      </ul>
    </li>
    <li>Run
      <ul>
        <li>Right-click on project plus-appengine-sample</li>
        <li>Run As &gt; Web Application</li>
        <li>Open <a href="http://localhost:8888">http://localhost:8888</a>
            in your browser.</li>
      </ul>
    </li>
  </ul>

</body>
</html>
